#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<int> findAnagrams(string s, string p)
    {
        vector<int> ret;
        int hush1[26] = { 0 };
        int hush2[26] = { 0 };
        for (auto e : p) hush1[e - 'a']++;

        for (int left = 0, right = 0, count = 0; right < s.size(); right++)
        {
            char in = s[right];
            hush2[in - 'a']++;
            if (hush2[in - 'a'] <= hush1[in - 'a']) count++;

            if (right - left + 1 > p.size())
            {
                char out = s[left];
                left++;
                if (hush2[out - 'a']-- <= hush1[out - 'a']) count--;
                //hush2[out - 'a']--;
            }
            if (count == p.size()) ret.push_back(left);
        }
        return ret;
    }
};